package belf.migrate.engine.admin.taskconf;

import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.util.Date;

@Data
@AllArgsConstructor
@NoArgsConstructor
public class TaskLogModel {

    private Date time;

    private String eventType;

    private String logMsg;

    private String logLevel;

    public TaskLogModel(String eventType, String logMsg, String logLevel) {
        this.time = new Date();
        this.eventType = eventType;
        this.logMsg = logMsg;
        this.logLevel = logLevel;
    }

    public String toJson() throws JsonProcessingException {
        ObjectMapper mapper = new ObjectMapper();
        return mapper.writer().writeValueAsString(this);
    }
}
